package cn.com.dhcc.turbo.service.stat;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.dhcc.app.core.exception.DaoException;
import cn.com.dhcc.app.core.exception.NiceException;
import cn.com.dhcc.app.core.exception.ServiceException;
import cn.com.dhcc.app.core.service.BaseService;
import cn.com.dhcc.app.pub.core.util.fusioncharts.Categories;
import cn.com.dhcc.app.pub.core.util.fusioncharts.Category;
import cn.com.dhcc.app.pub.core.util.fusioncharts.Chart;
import cn.com.dhcc.app.pub.core.util.fusioncharts.ChartDataset;
import cn.com.dhcc.app.pub.core.util.fusioncharts.ChartSet;
import cn.com.dhcc.app.pub.core.util.fusioncharts.ChartXmlUtil;
import cn.com.dhcc.app.pub.core.util.fusioncharts.NewChartXmlUtil;
import cn.com.dhcc.turbo.dao.stat.ExchStatStaticDao;
import cn.com.dhcc.turbo.entity.stat.ExchStatStatic;

@Service
public class ExchStatStaticService extends BaseService {
	@Autowired
	private ExchStatStaticDao dao; 
	
	
	/**本节点接收和发送次数
	 *  @param timeType
	  * @param mtime
	 * @param stat_level 
	 */
     public String getStLoNum(String timeType, String nt, String stat_level,String own_id)throws ServiceException {
           String msg = "";
           try {
        	   List< ExchStatStatic> exchStatStaticList = dao.getStLoNum(timeType, nt, stat_level, own_id);
        	   
        	   
               
                Chart chart = new Chart();
                String extProperty = "palette='1' plotgradientcolor='' canvasborderalpha='0' valuePadding='5' chartBottomMargin='5' " +
                		"chartLeftMargin='5' outCnvBaseFontSize='12' labeldisplay='STAGGER'  showplotborder='0' baseFontSize='10' " +
                		"showBorder='0' bgAlpha='0,0'  maxColWidth='30'  caption='"+nt+" 本节点发送/接收次数' numberSuffix='次' " +
                		"slantLabels='1' showSum='1'   showvalues='0'";
                		 
                chart.setExtProperty(extProperty);
               
                List< Category> cList = new ArrayList <Category >();
                Categories categories = new Categories();
                for(Iterator<ExchStatStatic> iterator = exchStatStaticList.iterator(); iterator.hasNext(); ) {
                	ExchStatStatic vo = iterator.next();
                	 
                    Category c0 = new Category(); 
             		c0.setLabel(vo.getNt());
            	    
                    cList.add(c0);
                }
                categories.setCategory(cList);
                chart.setCategories(categories);
               
                List< ChartDataset> dList = new ArrayList <ChartDataset >();
                ChartDataset d1 = new ChartDataset();
                d1.setSeriesName("发送" );
                d1.setColor("167ed5" );
                List< ChartSet> sets1 = new ArrayList <ChartSet >();
                for(Iterator< ExchStatStatic> iterator = exchStatStaticList.iterator(); iterator.hasNext(); ) {
                	ExchStatStatic vo = iterator.next();
                    ChartSet set = new ChartSet(); 
                     
                    	set.setValue(vo.getSendnum());
                     	set.setTooltext(vo.getName()+",发送:"+vo.getSendnum()+"次");
                        sets1.add(set); 
                }
               
                ChartDataset d2 = new ChartDataset();
                d2.setSeriesName("接收" );
                d2.setColor("ffce54" );
                List< ChartSet> sets2 = new ArrayList <ChartSet >();
                for(Iterator< ExchStatStatic> iterator = exchStatStaticList.iterator(); iterator.hasNext(); ) {
                	ExchStatStatic vo = iterator.next();
                    ChartSet set = new ChartSet(); 
                    	set.setValue(vo.getRevnum());
                    	set.setTooltext(vo.getName()+",接收："+vo.getRevnum()+"次");
                        sets2.add(set);
                     
                }
               
                d1.setSet(sets1);
                d2.setSet(sets2);
                dList.add(d1);
                dList.add(d2);
                chart.setDataset(dList);
               
                msg = NewChartXmlUtil.forXML(chart );
           } catch(DaoException e) {
                throw new ServiceException("数据统计失败", e);
           }
           return msg;
     }
     
//     /**本节点接收和发送频率
// 	 *  @param timeType
// 	  * @param mtime
// 	 * @param stat_level
// 	 * @return
// 	 * @throws DaoException
// 	 */
//     public String getStLoNumDtype(String timeType, String mtime, String stat_level)throws ServiceException {
//         String msg = "";
//         try {
//      	   List< ExchStatStatic> exchStatStaticList = null;
//      	   
//      	   exchStatStaticList = dao.getStLoNumDtype(timeType, mtime, stat_level);
//      	   
//      	   
//             
//              Chart chart = new Chart();
//              String extProperty = "chart palette='1' plotgradientcolor='' canvasborderalpha='0' valuePadding='5' chartBottomMargin='5' " +
//              		"chartLeftMargin='5' outCnvBaseFontSize='12' labeldisplay='STAGGER'  showplotborder='0' baseFontSize='10' showBorder='0' " +
//              		"bgAlpha='0,0' caption='"+mtime+"  数据发送/接收成功率' numberSuffix='%' yAxisMaxValue='100' showvalues='1'";
//              		 
//              chart.setExtProperty(extProperty);
//             
//              List< Category> cList = new ArrayList <Category>();
//              Categories categories = new Categories();
//              for(Iterator<ExchStatStatic> iterator = exchStatStaticList.iterator(); iterator.hasNext(); ) {
//              	ExchStatStatic vo = iterator.next();
//              	 
//                  Category c0 = new Category(); 
//           		   c0.setLabel(vo.getMtime());
//          	    
//                  cList.add(c0);
//              }
//              categories.setCategory(cList);
//              chart.setCategories(categories);
//             
//              List< ChartDataset> dList = new ArrayList <ChartDataset >();
//              ChartDataset d1 = new ChartDataset();
//              d1.setSeriesName("数据接收成功率" );
//              d1.setColor("167ed5" );
//              List< ChartSet> sets1 = new ArrayList <ChartSet >();
//              for(Iterator< ExchStatStatic> iterator = exchStatStaticList.iterator(); iterator.hasNext(); ) {
//              	ExchStatStatic vo = iterator.next();
//                  ChartSet set = new ChartSet(); 
//                  
//                  if(vo.getExch_type().equals("2")){
//                  	set.setValue(vo.getSumnum());
//                      sets1.add(set);
//                  }else {if(vo.getExch_type().equals("1"))
//                  {
//                  	set.setValue("0");
//                  	sets1.add(set);
//                  }
//                  }
//
//              }
//             
//              ChartDataset d2 = new ChartDataset();
//              d2.setSeriesName("数据发送成功率" );
//              d2.setColor("ffce54" );
//              List< ChartSet> sets2 = new ArrayList <ChartSet >();
//              for(Iterator< ExchStatStatic> iterator = exchStatStaticList.iterator(); iterator.hasNext(); ) {
//              	ExchStatStatic vo = iterator.next();
//                  ChartSet set = new ChartSet();
//                  if(vo.getExch_type().equals("1")){
//                  	set.setValue(vo.getSumnum());
//                      sets2.add(set);
//                  }else {if(vo.getExch_type().equals("2"))
//                  {
//                  	set.setValue("0");
//                  	sets2.add(set);
//                  }
//                  }
//              }
//             
//              d1.setSet(sets1);
//              d2.setSet(sets2);
//              dList.add(d1);
//              dList.add(d2);
//              chart.setDataset(dList);
//             
//              msg = ChartXmlUtil.forXML(chart );
//         } catch(DaoException e) {
//              throw new ServiceException("数据统计失败", e);
//         }
//         return msg;
//   }
    
     
     /**内外网交换频率
 	 *  @param timeType
 	  * @param mtime
 	 * @param stat_level 
 	 * @param own_id       1 发送 2 接收
 	 */
      public String getStLoNumNet(String timeType, String stat_level,String nt,String own_id)throws ServiceException {
            String msg = "";
            try {
         	   List< ExchStatStatic> exchStatStaticList = null;
         	  
         	   
         	   exchStatStaticList = dao.getStLoNumNet(timeType, stat_level, nt, own_id);
         	   String addw="";
         	   if(stat_level.equals("2")){
         		  ExchStatStatic Strname=dao.getDomNameInfos(own_id);
          		 String  newName=Strname.getName();
          		  addw="(业务域："+newName+")";
         	   } else if(stat_level.equals("3")){
         		   ExchStatStatic Strname=dao.getSysNameInfos(own_id);
         		 String  newName=Strname.getName();
         		  addw="(适配器："+newName+")";
         	   }else{
         		   addw="";
         	   }
         	   
                
                 Chart chart = new Chart();
                 String extProperty = "palette='1'  plotgradientcolor='' canvasborderalpha='0' valuePadding='5' chartBottomMargin='5'" +
                 		" chartLeftMargin='5' outCnvBaseFontSize='12' labeldisplay='STAGGER'  showplotborder='0' baseFontSize='10' plotSpacePercent='55' " +
                 		"showBorder='0' bgAlpha='0,0' caption='"+nt+" 本节点 "+addw+"' subcaption ='内外网交换频次' numberSuffix='次'   showvalues='0' showSum='1' ";
                 		 
                 chart.setExtProperty(extProperty);
                
                 List< Category> cList = new ArrayList <Category >();
                 Categories categories = new Categories();
                 for(Iterator<ExchStatStatic> iterator = exchStatStaticList.iterator(); iterator.hasNext(); ) {
                 	ExchStatStatic vo = iterator.next();
                 	 
                     Category c0 = new Category(); 
              		   c0.setLabel(vo.getNt());
             	    
                     cList.add(c0);
                 }
                 categories.setCategory(cList);
                 chart.setCategories(categories);
                
                 List< ChartDataset> dList = new ArrayList <ChartDataset >();
                 ChartDataset d1 = new ChartDataset();
                 d1.setSeriesName("发送" );
                 d1.setColor("167ed5" );
                 List< ChartSet> sets1 = new ArrayList <ChartSet >();
                 for(Iterator< ExchStatStatic> iterator = exchStatStaticList.iterator(); iterator.hasNext(); ) {
                 	ExchStatStatic vo = iterator.next();
                     ChartSet set = new ChartSet(); 
                      
                     	set.setValue(vo.getSendnum());
                     	set.setTooltext(vo.getName()+",发送:"+vo.getSendnum()+"次");
                         sets1.add(set);
                       

                 }
                
                 ChartDataset d2 = new ChartDataset();
                 d2.setSeriesName("接收" );
                 d2.setColor("ffce54" );
                 List< ChartSet> sets2 = new ArrayList <ChartSet >();
                 for(Iterator< ExchStatStatic> iterator = exchStatStaticList.iterator(); iterator.hasNext(); ) {
                 	ExchStatStatic vo = iterator.next();
                     ChartSet set = new ChartSet();
                      
                     	set.setValue(vo.getRevnum());
                     	set.setTooltext(vo.getName()+",接收:"+vo.getRevnum()+"次");
                         sets2.add(set);
                     
                 }
                
                 d1.setSet(sets1);
                 d2.setSet(sets2);
                 dList.add(d1);
                 dList.add(d2);
                 chart.setDataset(dList);
                
                 msg = NewChartXmlUtil.forXML(chart );
            } catch(DaoException e) {
                 throw new ServiceException("数据统计失败", e);
            }
            return msg;
      }
     
      /**内外网交换成功率（月/年）
   	 *  @param timeType
   	  * @param mtime
   	 * @param stat_level 
   	 * @param own_id   
   	 */
      public String getStLoNetRate(String timeType,String nt,String stat_level,String own_id) throws ServiceException {
			String msg="";
			try {
				List<ExchStatStatic> getAllList = null;
				getAllList = dao.getStLoNetRate(timeType, nt,stat_level,  own_id);
				 
				
				 Chart chart = new Chart(); 
				 
	             String extProperty = "palette='1'  plotgradientcolor='' canvasborderalpha='0' valuePadding='5' chartBottomMargin='5' " +
	             		"chartLeftMargin='5' outCnvBaseFontSize='12' labeldisplay='STAGGER'  showplotborder='0' baseFontSize='10' " +
	             		"showBorder='0' bgAlpha='0,0' showValues='1' caption='"+nt+" 内外网交换成功率' yAxisMaxValue='100'  numberSuffix='%' ";
	             chart.setExtProperty(extProperty);
	             
	             
	             List<ChartDataset> dList = new ArrayList<ChartDataset>();
	 			ChartDataset d1 = new ChartDataset();
	 			
	             List<ChartSet> set1 = new ArrayList<ChartSet>(); 
					for (Iterator<ExchStatStatic> iterator = getAllList.iterator(); iterator.hasNext();) {
						ExchStatStatic vo =  iterator.next();
						ChartSet set = new ChartSet();
						set.setLabel(vo.getNt());
						set.setValue(vo.getNum());
						set.setTooltext(vo.getName());
						set1.add(set);
					}
					
					d1.setSet(set1); 
					dList.add(d1); 
					chart.setSet(set1);
					msg = NewChartXmlUtil.forXML(chart);
	  
			} catch (DaoException e) {
				throw new ServiceException("数据统计失败", e);
			}
			
			return msg;
		}
      /**
		 * 与本节点交换频率最高的节点（月/年）
		 * @param NT 统计时间 
		 * @param timeType      
		 * @return   
		 * @throws DaoException
		 */ 
      public String getStLoRelNodeRate(String timeType, String nt)throws ServiceException {
          String msg = "";
          try {
       	   List< ExchStatStatic> exchStatStaticList = dao.getStLoRelNodeRate(timeType, nt);
       	 List<ExchStatStatic> sumList=new ArrayList<ExchStatStatic>();
      	 for(int i=0;i<exchStatStaticList.size();i++){
      		ExchStatStatic vo=exchStatStaticList.get(i);
      		int a=Integer.parseInt(vo.getRevnum());
      		int b=Integer.parseInt(vo.getSendnum());
      		int sum=a+b; 
      		vo.setSumnum(sum+"");
      		sumList.add(vo);
      	 }
      	Collections.sort(sumList, new Comparator<ExchStatStatic>(){

			public int compare(ExchStatStatic o1, ExchStatStatic o2) {
				int s1=Integer.parseInt(o1.getSumnum());
				int s2=Integer.parseInt(o2.getSumnum());
				if(s2>s1){
					return 1;
				} else if(s2==s1){
					return 0;
				}else {
					return -1;
				}  
			}  
      	});


              
               Chart chart = new Chart();
               String extProperty = "palette='1' plotgradientcolor='' canvasborderalpha='0' valuePadding='5' chartBottomMargin='5' chartLeftMargin='5' " +
               		"outCnvBaseFontSize='12' labeldisplay='STAGGER'  showplotborder='0' baseFontSize='10' showBorder='0' bgAlpha='0,0' plotSpacePercent='55' " +
               		"caption='"+nt+"  同本节点交换频次最高的节点(top10)' xAxisName='所属节点'  slantLabels='1' showSum='1' numberSuffix='次'   showvalues='0' ";
               		 
               chart.setExtProperty(extProperty);
              
               List< Category> cList = new ArrayList <Category >();
               Categories categories = new Categories();
               for(Iterator<ExchStatStatic> iterator = sumList.iterator(); iterator.hasNext(); ) {
               	ExchStatStatic vo = iterator.next();
               	 
                   Category c0 = new Category(); 
            		   c0.setLabel(vo.getName());
           	    
                   cList.add(c0);
               }
               categories.setCategory(cList);
               chart.setCategories(categories);
              
               List< ChartDataset> dList = new ArrayList <ChartDataset >();
               ChartDataset d1 = new ChartDataset();
               d1.setSeriesName("发送" );
               d1.setColor("167ed5" );
               List< ChartSet> sets1 = new ArrayList <ChartSet >();
               for(Iterator< ExchStatStatic> iterator = sumList.iterator(); iterator.hasNext(); ) {
               	ExchStatStatic vo = iterator.next();
                   ChartSet set = new ChartSet();  
                   	set.setValue(vo.getSendnum()); 
                   	set.setTooltext(vo.getName()+",发送:"+vo.getSendnum()+"次");
                       sets1.add(set); 
               }
              
               ChartDataset d2 = new ChartDataset();
               d2.setSeriesName("接收" );
               d2.setColor("ffce54" );
               List< ChartSet> sets2 = new ArrayList <ChartSet >();
               for(Iterator< ExchStatStatic> iterator = sumList.iterator(); iterator.hasNext(); ) {
               	ExchStatStatic vo = iterator.next();
                   ChartSet set = new ChartSet();
                    
                   	set.setValue(vo.getRevnum()); 
                   	set.setTooltext(vo.getName()+",接收:"+vo.getRevnum()+"次");
                       sets2.add(set);
                   
               }
              
               d1.setSet(sets1);
               d2.setSet(sets2);
               dList.add(d1);
               dList.add(d2);
               chart.setDataset(dList);
              
               msg = NewChartXmlUtil.forXML(chart );
          } catch(DaoException e) {
               throw new ServiceException("数据统计失败", e);
          }
          return msg;
    }
      
      /**
		 * 与本节点交换频率最高的节点（月/年）
		 * @param NT 统计时间 
		 * @param timeType      
		 * @return   
		 * @throws DaoException
		 */ 
      
		  public String getStLoRelSysRate(String timeType, String nt)throws ServiceException {
	          String msg = "";
	          try {
	       	   List< ExchStatStatic> exchStatStaticList  = dao.getStLoRelSysRate(timeType, nt);
	       	   
	       	 List<ExchStatStatic> sumList=new ArrayList<ExchStatStatic>();
	      	 for(int i=0;i<exchStatStaticList.size();i++){
	      		ExchStatStatic vo=exchStatStaticList.get(i);
	      		int a=Integer.parseInt(vo.getRevnum());
	      		int b=Integer.parseInt(vo.getSendnum());
	      		int sum=a+b; 
	      		vo.setSumnum(sum+"");
	      		sumList.add(vo);
	      	 }
	      	Collections.sort(sumList, new Comparator<ExchStatStatic>(){

				public int compare(ExchStatStatic o1, ExchStatStatic o2) {
					int s1=Integer.parseInt(o1.getSumnum());
					int s2=Integer.parseInt(o2.getSumnum());
					if(s2>s1){
						return 1;
					} else if(s2==s1){
						return 0;
					}else {
						return -1;
					}  
				}  
	      	});

	       	   
	       	   
	              
	               Chart chart = new Chart();
	               String extProperty = "palette='1' plotgradientcolor='' canvasborderalpha='0' valuePadding='5' chartBottomMargin='5' " +
	               		"chartLeftMargin='5' outCnvBaseFontSize='12' labeldisplay='STAGGER'  showplotborder='0' baseFontSize='10' plotSpacePercent='50' showBorder='0' " +
	               		"bgAlpha='0,0'  caption='"+nt+"  同本节点交换频次最高的适配器(top10)' xAxisName='所属适配器' numberSuffix='次'  " +
	               		"  slantLabels='1' showSum='1'   showvalues='0' ";
	               		 
	               chart.setExtProperty(extProperty);
	              
	               List< Category> cList = new ArrayList <Category >();
	               Categories categories = new Categories();
	               for(Iterator<ExchStatStatic> iterator = sumList.iterator(); iterator.hasNext(); ) {
	               	ExchStatStatic vo = iterator.next();
	               	 
	                   Category c0 = new Category(); 
	            		   c0.setLabel(vo.getName());
	           	    
	                   cList.add(c0);
	               }
	               categories.setCategory(cList);
	               chart.setCategories(categories);
	              
	               List< ChartDataset> dList = new ArrayList <ChartDataset >();
	               ChartDataset d1 = new ChartDataset();
	               d1.setSeriesName("发送" );
	               d1.setColor("167ed5" );
	               List< ChartSet> sets1 = new ArrayList <ChartSet >();
	               for(Iterator< ExchStatStatic> iterator = sumList.iterator(); iterator.hasNext(); ) {
	               	ExchStatStatic vo = iterator.next();
	                   ChartSet set = new ChartSet(); 
	                    
	                   	set.setValue(vo.getSendnum()); 
	                   	set.setTooltext(vo.getName()+",发送:"+vo.getSendnum()+"次");
	                       sets1.add(set);
	                     

	               }
	              
	               ChartDataset d2 = new ChartDataset();
	               d2.setSeriesName("接收" );
	               d2.setColor("ffce54" );
	               List< ChartSet> sets2 = new ArrayList <ChartSet >();
	               for(Iterator< ExchStatStatic> iterator = sumList.iterator(); iterator.hasNext(); ) {
	               	ExchStatStatic vo = iterator.next();
	                   ChartSet set = new ChartSet();
	                    
	                   	set.setValue(vo.getRevnum()); 
	                   	set.setTooltext(vo.getName()+",接收:"+vo.getRevnum()+"次");
	                       sets2.add(set);
	                   
	               }
	              
	               d1.setSet(sets1);
	               d2.setSet(sets2);
	               dList.add(d1);
	               dList.add(d2);
	               chart.setDataset(dList);
	              
	               msg = NewChartXmlUtil.forXML(chart );
	          } catch(DaoException e) {
	               throw new ServiceException("数据统计失败", e);
	          }
	          return msg;
	    }
		  /**本节点发送（按适配器)
		  	 *  @param timeType
		  	  * @param nt 
		  	 * @return
		  	 * @throws DaoException
		  	 */
		  	 public String getStLoNumSysSend(String timeType,String nt) throws ServiceException {
					String msg="";
					try {
						List<ExchStatStatic> getAllList = null;
						getAllList = dao.getStLoNumSysSend(timeType, nt);
						 
						
						 Chart chart = new Chart(); 
						 
			             String extProperty = "palette='5' baseFontSize='12' use3dlighting='0' showBorder='0'  bgAlpha='0,0' " +
			             		"showshadow='0'  caption='"+nt+"  本节点发送频次' subcaption='(按适配器)' numberSuffix='次' ";
			             chart.setExtProperty(extProperty);
			             
			             
			             List<ChartDataset> dList = new ArrayList<ChartDataset>();
			 			ChartDataset d1 = new ChartDataset();
			 			
			             List<ChartSet> set1 = new ArrayList<ChartSet>(); 
							for (Iterator<ExchStatStatic> iterator = getAllList.iterator(); iterator.hasNext();) {
								ExchStatStatic vo =  iterator.next();
								ChartSet set = new ChartSet(); 
								set.setLabel(vo.getName());
								set.setValue(vo.getNum()); 
								set1.add(set);
							}
							
							d1.setSet(set1); 
							dList.add(d1); 
							chart.setSet(set1);
							msg = ChartXmlUtil.forXML(chart);
			  
					} catch (DaoException e) {
						throw new ServiceException("数据统计失败", e);
					}
					
					return msg;
				}
		  	 
		  	 /**本节点接收（按适配器)
			  	 *  @param timeType
			  	  * @param nt 
			  	 * @return
			  	 * @throws DaoException
			  	 */
			  	 public String getStLoNumSysRev(String timeType,String nt) throws ServiceException {
						String msg="";
						try {
							List<ExchStatStatic> getAllList = null;
							getAllList = dao.getStLoNumSysRev(timeType, nt);
							 
							
							 Chart chart = new Chart(); 
							 
				             String extProperty = "palette='5' baseFontSize='12' use3dlighting='0' showBorder='0'  bgAlpha='0,0' " +
				             		"showshadow='0'  caption='"+nt+" 本节点接收频次' subcaption='(按适配器)' numberSuffix='次' ";
				             chart.setExtProperty(extProperty);
				             
				             
				             List<ChartDataset> dList = new ArrayList<ChartDataset>();
				 			ChartDataset d1 = new ChartDataset();
				 			
				             List<ChartSet> set1 = new ArrayList<ChartSet>(); 
								for (Iterator<ExchStatStatic> iterator = getAllList.iterator(); iterator.hasNext();) {
									ExchStatStatic vo =  iterator.next();
									ChartSet set = new ChartSet(); 
									set.setLabel(vo.getName());
									set.setValue(vo.getNum()); 
									set1.add(set);
								}
								
								d1.setSet(set1); 
								dList.add(d1); 
								chart.setSet(set1);
								msg = ChartXmlUtil.forXML(chart);
				  
						} catch (DaoException e) {
							throw new ServiceException("数据统计失败", e);
						}
						
						return msg;
					}
			  	 
			 	/**本节点发送（按数据分类)
				  	 *  @param timeType
				  	  * @param nt 
				  	  * @param stat_level
				  	  * @param  own_id
				  	  * EXCH_TYPE =1 发送
				  	 * @return 
				  	 * @throws DaoException
				  	 */
			  	 public String getStLoNumDtypeSend(String timeType,String nt,String stat_level,String own_id) throws ServiceException {
						String msg="";
						try {
							List<ExchStatStatic> getAllList = dao.getStLoNumDtypeSend(timeType, nt, stat_level, own_id);
							 
							  String addw="";
				         	   if(stat_level.equals("2")){
				         		  ExchStatStatic Strname=dao.getDomNameInfos(own_id);
				          		 String  newName=Strname.getName();
				          		  addw="(业务域："+newName+")";
				         	   } else if(stat_level.equals("3")){
				         		   ExchStatStatic Strname=dao.getSysNameInfos(own_id);
				         		 String  newName=Strname.getName();
				         		  addw="(适配器："+newName+")";
				         	   }else{
				         		   addw="";
				         	   }
							
							 Chart chart = new Chart(); 
							 
				             String extProperty = "palette='5' baseFontSize='12'  use3dlighting='0' showBorder='0'  bgAlpha='0,0'  showshadow='0'  " +
				             		"caption='"+nt+" 本节点"+addw+"发送频次' subcaption='(按数据分类)' numberSuffix='次' ";
				             chart.setExtProperty(extProperty);
				             
				             
				             List<ChartDataset> dList = new ArrayList<ChartDataset>();
				 			ChartDataset d1 = new ChartDataset();
				 			
				             List<ChartSet> set1 = new ArrayList<ChartSet>(); 
								for (Iterator<ExchStatStatic> iterator = getAllList.iterator(); iterator.hasNext();) {
									ExchStatStatic vo =  iterator.next();
									ChartSet set = new ChartSet(); 
									set.setLabel(vo.getName());
									set.setValue(vo.getNum()); 
									set1.add(set);
								}
								
								d1.setSet(set1); 
								dList.add(d1); 
								chart.setSet(set1);
								msg = ChartXmlUtil.forXML(chart);
				  
						} catch (DaoException e) {
							throw new ServiceException("数据统计失败", e);
						}
						
						return msg;
					}
			  	 
			  	 
			  	/**本节点接收（按数据分类)
				  	 *  @param timeType
				  	  * @param nt 
				  	  * @param stat_level
				  	  * @param  own_id
				  	  * EXCH_TYPE =2  接收
				  	 * @return 
				  	 * @throws DaoException
				  	 */
			  	 public String getStLoNumDtypeRev(String timeType,String nt,String stat_level,String own_id) throws ServiceException {
						String msg="";
						try {
							List<ExchStatStatic> getAllList = dao.getStLoNumDtypeRev(timeType, nt, stat_level, own_id);
							 
							  String addw="";
				         	   if(stat_level.equals("2")){
				         		  ExchStatStatic Strname=dao.getDomNameInfos(own_id);
				          		 String  newName=Strname.getName();
				          		  addw="(业务域："+newName+")";
				         	   } else if(stat_level.equals("3")){
				         		   ExchStatStatic Strname=dao.getSysNameInfos(own_id);
				         		 String  newName=Strname.getName();
				         		  addw="(适配器："+newName+")";
				         	   }else{
				         		   addw="";
				         	   }
							
							 Chart chart = new Chart(); 
							 
				             String extProperty = "palette='5' baseFontSize='12'  use3dlighting='0' showBorder='0'  bgAlpha='0,0'  showshadow='0'  " +
				             		"caption='"+nt+" 本节点"+addw+"接收频次' subcaption='(按数据分类)' numberSuffix='次' ";
				             chart.setExtProperty(extProperty);
				             
				             
				             List<ChartDataset> dList = new ArrayList<ChartDataset>();
				 			ChartDataset d1 = new ChartDataset();
				 			
				             List<ChartSet> set1 = new ArrayList<ChartSet>(); 
								for (Iterator<ExchStatStatic> iterator = getAllList.iterator(); iterator.hasNext();) {
									ExchStatStatic vo =  iterator.next();
									ChartSet set = new ChartSet(); 
									set.setLabel(vo.getName());
									set.setValue(vo.getNum()); 
									set1.add(set);
								}
								
								d1.setSet(set1); 
								dList.add(d1); 
								chart.setSet(set1);
								msg = ChartXmlUtil.forXML(chart);
				  
						} catch (DaoException e) {
							throw new ServiceException("数据统计失败", e);
						}
						
						return msg;
					}
			  	 
			  	 
		  	 
     /**
   		 * 获取sysinfo信息；
   		 * */
   		public List<ExchStatStatic> getSysInfos() throws NiceException {
   			try {
   				return dao.getSysInfos();
   			}   catch (DaoException e) {
   				throw new NiceException("获取数据源信息失败", e);
   			}
   		}
   		
        /**
         * 获取Dominfo信息；
      	* */
      		public List<ExchStatStatic> getDomInfos() throws NiceException {
      			try {
      				return dao.getDomInfos();
      			}   catch (DaoException e) {
      				throw new NiceException("获取数据源信息失败", e);
      			}
      		}
    
}
